#!/bin/bash
# This is the statistical engine for the CARBLog shell scripts.
# 
# Traps:
# signal CTRL-C (2) delete temp files
# signal QUIT (3) delete temp files
# signal TERM (15) delete temp files
# set traps
trap cleanup 1 2 3 6
cleanup()
{
echo "Caught Signal ... quitting."
exit 1
}
# loop forever
while :
do
datestamp="$saroad-`date "+%Y-%m-%d"`"
log=Data/$datestamp 
timestamp=`date "+%H:%M.%S"`
# DEFINE A VARIABLE FOR THE NUMBER OF OTHER CHANNELS
# NOT INCLUDING RMYOUNG BEING TRACKED
channels=$(cat Config/config | grep _nam | grep -v \# | wc -l)
nmbr=$(echo "($channels)*15" | bc)
# READ the last 15 * # of Channels
entries=$(tail -n $nmbr $log | grep "Azim" | wc -l );
minute=$(echo `date "+%M"`)
echo $minute
egg="01 02 03 04 06 08 10 15 30 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 55 57 00"

for i in $egg
	do 
		if ( $i  $minute ); then
			echo "i is".$i." & minute is".$minute			
			echo "I'm supposed to be tabulating!!!! - case A";
		else 
			echo "Not Yet"
		fi;
	done;	

#tail -n $nmbr $log | grep "Azim" > /tmp/stats_$$
#echo "summarizing...";  
#echo "U 15 MIN STATISTICS:" >> /tmp/SUMMARY_$$;
#cat /tmp/stats_$$ | nawk -f sys_resources/stats.nawk 2 >> /tmp/SUMMARY_$$; 
#cat /tmp/SUMMARY_$$;
sleep 15; 
#fi  
done;
exit;
